﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class EvalReward : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void GridView_Reward_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        if (Utility.HasNullValue(e.NewValues))
        {
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "输入不能为空！";
            e.Cancel = true;
            return;
        }

        bool valid = true;

        string bonus = e.NewValues["EvalHigh"].ToString();
        int result;
        if (!int.TryParse(bonus, out result) || result <= 0)
        {
            valid = false;
        }

        bonus = e.NewValues["EvalMiddle"].ToString();
        if (!int.TryParse(bonus, out result) || result <= 0)
        {
            valid = false;
        }

        bonus = e.NewValues["EvalLow"].ToString();
        if (!int.TryParse(bonus, out result) || result <= 0)
        {
            valid = false;
        }   

        // Set the error message label.
        if (!valid)
        {
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "请输入正数。";
            e.Cancel = true;
        }
        else
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "";
    }
    protected void GridView_Reward_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        Utility.FormatGridview(GridView_Reward, e);
    }
}
